//
//  TransparentNavigationBar.m
//  UIControls
//
//  Created by 21CN Vgo on 12-3-23.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import "TransparentNavigationBar.h"


@implementation TransparentNavigationBar

// Override draw rect to avoid
// background coloring
- (void)drawRect:(CGRect)rect {
    // do nothing in here
	if (!_bTransparent) {
		[super drawRect:rect];
	}
}

// Set properties to make background
// translucent.
- (void) applyTranslucentBackground
{
	self.backgroundColor = [UIColor clearColor];
	self.opaque = NO;
	[self setNeedsDisplay];
	//self.translucent = YES;
}

// Override init.
- (id) init
{
	self = [super init];
	if (self) {
		_bTransparent = NO;
		//[self applyTranslucentBackground];
		// Initialization code.
		
	}
	return self;
}

// Override initWithFrame.
- (id) initWithFrame:(CGRect) frame
{
	self = [super initWithFrame:frame];
	if (self) {
		[self applyTranslucentBackground];
		// Initialization code.
	}
	
	return self;
}

- (void)setTransparent
{
	_bTransparent = YES;
	[self applyTranslucentBackground];
}

- (void)setUnTransparent
{
	_bTransparent = NO;
	//[self setNeedsDisplay];
}

@end
